
const App = getApp();
const navigationBarHeight = (getApp().diygwstatusBarHeight + 44) + 'px'
Page({
data: {
          radioItems2:[{"checked":true,"label":"男","value":"男"},{"checked":false,"label":"女","value":"女"}],
     buttons3:[
				{type:'submit',url:App.renderUrl('empty','index'),title:``}
			],
	users:[]
},

showModal(message) {
   App.WxService.showModal({
    	title: '友情提示',
    	content: message,
    	showCancel: !1,
   });
},
onShareAppMessage: function () {
},
onLoad(option) {
	if (option){
      this.setData({
         globalOption: option
      })
    }
},
onShow(){
     this.getForm1();
     this.chushi();
},
navigateTo(e) {
  App.navigateTo(e.currentTarget.dataset.url, e.currentTarget.dataset);
},
getForm1(){
	this.WxValidate = App.WxValidate({
		mname: {
			required:{
				message:'姓名：不能为空哟'
			}
		},
		age: {
			required:{
				message:'年龄：不能为空哟'
			},
			digits:{
				message:'年龄：请输入有效的整数'
			}
		},
		tel: {
			tel:{
				message:'手机号码：请输入11位的手机号码'
			}
		}
})
},
formSubmit1: function (e) {
	if (!this.WxValidate.checkForm(e)) {
		const error = this.WxValidate.errorList[0]
		var msg = `${error.msg}`;
    	this.showModal(msg);
		return false
	}else{
		var data = e.detail.value;
		data =App.Tools.extend(data,{
			f:1,
			id:wx.getStorageSync("mid")
		});
		App.HttpService.saveData(data,"/member_Edit").then(data => {
			App.WxService.showToast({
				title: "修改成功!",
				icon: 'success',
				duration: 1000,
			});
			setTimeout(function () {
				wx.navigateBack();
			}, 1000)
		});
	  }
},
formReset1: function() {
    console.log('form发生了reset事件')
},
changesex: function (value) {
	if(value.detail){
		value = value.detail.value
	}
    var radioItems2 = this.data.radioItems2;
    for (var i = 0, len = radioItems2.length; i < len; ++i) {
        radioItems2[i].checked = radioItems2[i].value == value;
    }
    this.setData({
        radioItems2: radioItems2
    });
},
	chushi(){
		var that=this;
		//调用数据
		let param = {
			loadmsg:`正在加载中`,
			f:1,
			mid:wx.getStorageSync("mid")
		};

		App.HttpService.getData(param,"/member_List").then(data=>{
			console.log(data);
			if(data[0].sex=="男")
			{
				that.changesex("男");
			}
			else
			{
				that.changesex("女");
			}
			this.setData({
				users: data
			});
		});
	}

})
